import Page
from Page import Personal
from Base.Base import Base
from selenium.webdriver.common.by import By


class PersonalCarinfo(Base):
    """
     车辆信息
    """

    # TODO: 发动机号暂时无内容,无法获取

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.carinfo_home_btn = (By.XPATH, Personal.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.carinfo_back_btn = (By.XPATH, Personal.RESOURCE_ID.format('ivBack'))

        # 车辆图片
        self.carinfo_car_image_img = (By.XPATH, Personal.RESOURCE_ID.format("car_pic"))

        # 车型名称
        self.carinfo_car_model_name_text = (By.XPATH, Personal.RESOURCE_ID.format("textView5"))

        # 车型文案
        self.carinfo_car_content_text = (By.XPATH, Personal.RESOURCE_ID.format("models"))

        # 车架号名称
        self.carinfo_car_frame_name_text = (By.XPATH, Personal.RESOURCE_ID.format("textView7"))

        # 车架号内容
        # self.carinfo_car_frame_content_text = (By.XPATH, Personal.RESOURCE_ID.format("chassis_number"))

        # 发动机号名称
        self.carinfo_car_engine_name_text = (By.XPATH, Personal.RESOURCE_ID.format("textView8"))

        # 发动机号内容(目前获取不到,暂时无法使用)
        # self.carinfo_car_engine_content_text = (By.XPATH, Personal.RESOURCE_ID.format(("")))

        # ICCID名称
        self.carinfo_car_iccid_name_text = (By.XPATH, Personal.RESOURCE_ID.format("textView18"))

        # ICCID内容
        self.carinfo_car_iccid_content_text = (By.XPATH, Personal.RESOURCE_ID.format("iccid_number"))

        # 车牌号名称
        self.carinfo_car_number_name_text = (By.XPATH, Personal.RESOURCE_ID.format("tv_car_number"))

        # 车牌号按钮
        self.carinfo_car_number_name_btn = (By.XPATH, Personal.RESOURCE_ID.format("tv_number_province"))

        # 车牌号输入框
        self.carinfo_car_number_concern_input = (By.XPATH, Personal.RESOURCE_ID.format("et_number_value"))

        # 手机号码名称
        self.carinfo_iphone_number_name_text = (By.XPATH, Personal.RESOURCE_ID.format("tv_phone"))

        # 基础信息标题按钮
        self.carinfo_basic_information_btn = (By.XPATH, Personal.RESOURCE_ID.format("tv_basic"))

        # 授权信息标题按钮
        self.carinfo_authorization_information_btn = (By.XPATH, Personal.RESOURCE_ID.format("tv_authorize"))

        # 认证车牌按钮
        self.carinfo_certified_license_plate_btn = (By.XPATH, Personal.RESOURCE_ID.format("tv_question_mark"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.carinfo_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.carinfo_back_btn)

    def get_car_image(self):
        """
        获取车辆图片

        :return:获取元素
        """
        return self.find_element_o(self.carinfo_car_image_img)

    def get_car_model_name(self):
        """
        获取车型名称

        :return:获取元素
        """
        return self.find_element_o(self.carinfo_car_model_name_text)

    def get_car_content(self):
        """
        获取车型名称内容

        :return: 获取元素
        """
        return self.find_element_o(self.carinfo_car_content_text)

    def get_car_frame_name(self):
        """
        获取车架号名称

        :return: 获取元素
        """
        return self.find_element_o(self.carinfo_car_frame_name_text)

    # def get_car_frame_content(self):
    #     """
    #     获取车架号内容
    #
    #     :return: 获取元素
    #     """
    #     return self.find_element_o(self.carinfo_car_frame_content_text)

    def get_car_engine_name(self):
        """
        获取车架号名称

        :return: 获取元素
        """
        return self.find_element_o(self.carinfo_car_engine_name_text)

    def get_car_iccid_name(self):
        """
        获取iccid名称

        :return: 获取元素
        """
        return self.find_element_o(self.carinfo_car_iccid_name_text)

    def get_car_iccid_content(self):
        """
        获取iccid内容

        :return: 获取元素
        """
        return self.find_element_o(self.carinfo_car_iccid_content_text)

    def get_car_number_name(self):
        """
        获取车牌号名称

        :return: 获取元素
        """
        return self.find_element_o(self.carinfo_car_number_name_text)

    def click_car_number_name(self):
        """
        点击车牌号按钮

        :return: None
        """
        self.click_element(self.carinfo_car_number_name_btn)

    def input_car_number_concern(self, index):
        """
        输入车牌号输入框

        index为输入内容
        :return: None
        """
        self.input_text(self.carinfo_car_number_concern_input, index)

    def get_car_number_concern(self):
        """
        获取输入车牌号

        :return: 获取元素
        """
        return self.find_element_o(self.carinfo_car_number_concern_input)

    def get_iphone_number_name(self):
        """
        获取手机电话号码标题

        :return: 获取元素
        """
        return self.find_element_o(self.carinfo_iphone_number_name_text)

    def click_basic_information(self):
        """
        点击基础信息标题按钮

        :return: None
        """
        self.click_element(self.carinfo_basic_information_btn)

    def get_basic_information(self):
        """
        获取基础信息标题按钮属性

        :return: None
        """
        return self.find_element_o(self.carinfo_basic_information_btn)

    def click_authorization_information(self):
        """
        点击授权信息标题按钮

        :return: None
        """
        self.click_element(self.carinfo_authorization_information_btn)

    def get_authorization_information(self):
        """
        获取授权信息标题按钮属性

        :return: None
        """
        return self.find_element_o(self.carinfo_authorization_information_btn)

    def click_certified_license_plate(self):
        """
        点击认证车牌按钮

        :return: None
        """
        self.click_element(self.carinfo_certified_license_plate_btn)

    def is_display_personal_car_info(self):
        """
        是否存在车辆信息页面

        :return: bool
        """
        return self.is_display(self.carinfo_car_model_name_text)
